public class test3 {
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
        int n= 9;
        int[] res = target(n,arr);
        System.out.println(myString(res));
    }
    public static int[] target(int n,int[] arr) {
        int num1 = 0,num2 = 0;
        for(int i=0;i<arr.length;i++){
            for(int j=i+1;j<arr.length;j++){
                if(arr[i] + arr[j] == n){
                    num1 = i;
                    num2 = j;
                }
            }
        }
        int[] res = new int[2];
        res[0] = num1;
        res[1] = num2;
        return res;
    }
    public static String myString(int[] arr) {
        String ret = "[";
        for (int i = 0; i < arr.length; i++) {
            ret += arr[i];
            if (i != arr.length - 1) {
                ret += ",";
            }
        }
        ret += "]";
        return ret;
    }
}
